package com.example.demospring3_2.config;

import com.example.demospring3_2.service.DemoService;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.reactive.function.client.support.WebClientAdapter;
import org.springframework.web.service.invoker.HttpServiceProxyFactory;

@Configuration
public class WenConfig {
    @Bean
    WebClient webClient(ObjectMapper objectMapper) {
        return WebClient.builder().build();
    }
    @Bean
    DemoService demoService(WebClient webClient) {
        HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builderFor(WebClientAdapter.create(webClient)).build();
        return proxyFactory.createClient(DemoService.class);
    }
}
